home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / misc1 / iv26_w30.zip / INTERVIE / PANNER.H < prev    next >
C/C++ Source or Header  |  1980-01-03  |  3KB  |  89 lines

  1. /*
  2.  * Copyright (c) 1987, 1988, 1989 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, distribute, and sell this software and its
  5.  * documentation for any purpose is hereby granted without fee, provided
  6.  * that the above copyright notice appear in all copies and that both that
  7.  * copyright notice and this permission notice appear in supporting
  8.  * documentation, and that the name of Stanford not be used in advertising or
  9.  * publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.  Stanford makes no representations about
  11.  * the suitability of this software for any purpose.  It is provided "as is"
  12.  * without express or implied warranty.
  13.  *
  14.  * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  15.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  17.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  18.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  19.  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  20.  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  21.  */
  22.  
  23. /*
  24.  * Panner - an interactor for two-dimensional scrolling and zooming.
  25.  */
  26.  
  27. #ifndef panner_h
  28. #define panner_h
  29.  
  30. #include <InterViews/scene.h>
  31.  
  32. class Panner : public MonoScene {
  33. public:
  34.     Panner(Interactor*, int size = 0);
  35.     Panner(const char*, Interactor*, int size = 0);
  36.     Panner(Interactor*, int size, Painter*);
  37. protected:
  38.     int size;
  39.  
  40.     virtual void Reconfig();
  41. private:
  42.     Interactor* adjusters;
  43.     Interactor* slider;
  44.  
  45.     void Init(Interactor*, int);
  46. };
  47.  
  48. class Slider : public Interactor {
  49. public:
  50.     Slider(Interactor*);
  51.     Slider(const char*, Interactor*);
  52.     Slider(Interactor*, Painter*);
  53.     ~Slider();
  54.  
  55.     virtual void Draw();
  56.     virtual void Handle(Event&);
  57.     virtual void Update();
  58.     virtual void Reshape(Shape&);
  59.     virtual void Resize();
  60. protected:
  61.     virtual void Reconfig();
  62.     virtual void Redraw(Coord, Coord, Coord, Coord);
  63. private:
  64.     Interactor* interactor;
  65.     Perspective* view;
  66.     Perspective* shown;
  67.     Coord left, bottom, right, top;
  68.     Coord prevl, prevb, prevr, prevt;    // for smart update
  69.     Coord llim, blim, rlim, tlim;    // sliding limits
  70.     boolean constrained, syncScroll;
  71.     int moveType;
  72.     Coord origx, origy;
  73.  
  74.     void Init(Interactor*);
  75.     Coord ViewX(Coord);
  76.     Coord ViewY(Coord);
  77.     Coord SliderX(Coord);
  78.     Coord SliderY(Coord);
  79.     void CalcLimits(Event&);        // calculate sliding limits
  80.     void SizeKnob();            // calculate size of slider knob
  81.     boolean Inside(Event&);        // true if inside slider knob
  82.     void Constrain(Event&);        // constrain slider knob motion
  83.     void Move(Coord dx, Coord dy);    // move view to reflect slider position
  84.     void Slide(Event&);            // rubberband rect while mousing
  85.     void Jump(Event&);            // for click outside knob
  86. };
  87.  
  88. #endif
  89.